#version 120

varying vec3 l;
varying vec3 v;
varying vec3 n;

uniform vec4 uColor;
uniform float uBrightnes;
uniform sampler2D uTexture;

void main (void)
{
	vec4 tex = texture2D(uTexture, gl_TexCoord[0].xy);
	vec4 diffColor = uColor + tex; 	
	diffColor.a = uColor.a;
    const vec4  specColor = vec4 ( 0.5, 0.5, 0.5, 1.0 );
    const float specPower = 30.0;

    vec3 n2   = normalize ( n );
    vec3 l2   = normalize ( l );
    vec3 v2   = normalize ( v );
    vec3 r    = reflect ( -v2, n2 );
    vec4 diff = diffColor * max ( dot ( n2, l2 ), 0.25 );
    vec4 spec = specColor * pow ( max ( dot ( l2, r ), 0.25 ), specPower );
	diff.xyz *= uBrightnes;
	spec.xyz *= uBrightnes;	
	diff.a = diffColor.a;		
    //gl_FragColor = max((diff + spec), vec4(0.2, 0.2, 0.2, 1) * tex);
	gl_FragColor = diff + spec;
	gl_FragColor.a = diffColor.a;
}